//
//  LCAreaTaskViewController.m
//  lechuang
//
//  Created by Mr_hi on 2023/3/31.
//  Copyright © 2023 Mooyi. All rights reserved.
//

#import "LCAreaTaskViewController.h"
#import "LCTaskListViewController.h"
#import "XLPageViewController.h"


@interface LCAreaTaskViewController ()<XLPageViewControllerDelegate,XLPageViewControllerDataSrouce>

@property (nonatomic, strong) XLPageViewControllerConfig *config;
@property (nonatomic, strong) XLPageViewController *pageViewController;

@property (strong, nonatomic)NSArray * titleArr;

@end

@implementation LCAreaTaskViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.titleArr = @[@"热门推荐",@"简单任务",@"体验推荐",@"新人区",@"试玩反佣"];
    [self inistalConfig];
    [self SetMainUI];
}

- (void)inistalConfig {
    self.config = [XLPageViewControllerConfig defaultConfig];
    self.config.titleViewAlignment = 1;
    self.config.titleSelectedFont = [UIFont systemFontOfSize:12];
    self.config.titleNormalFont = [UIFont systemFontOfSize:12];
    self.config.titleNormalColor = [UIColor colorWithHexString:@"#666666"];
    self.config.titleSelectedColor = [UIColor colorWithHexString:@"#FC5353"];
    self.config.titleViewHeight = 35;
    self.config.titleWidth = (ScreenW-34)/(self.titleArr.count);
    self.config.titleSpace = 0;
    self.config.shadowLineColor = [UIColor clearColor];
    self.config.shadowImage = [UIImage imageNamed:@"lc_task_triangle_icon"];
    self.config.shadowLineHeight = 5;
    self.config.shadowLineWidth = 12;
    self.config.separatorLineColor = [UIColor clearColor];
    self.config.segmentedTintColor = [UIColor clearColor];
}

- (void)SetMainUI {
    self.pageViewController = [[XLPageViewController alloc] initWithConfig:self.config];
    self.pageViewController.view.frame = self.view.bounds;
    self.pageViewController.delegate = self;
    self.pageViewController.dataSource = self;
    self.pageViewController.selectedIndex = 0;
    self.pageViewController.bounces = NO;
    [self.view addSubview:self.pageViewController.view];
    self.pageViewController.view.backgroundColor = [UIColor colorWithHexString:@"#F2F2F2"];
}

- (int)orderTypeWithIndex:(NSInteger)index {
    switch (index) {
        case 0: {
            return 4;
        } break;
        case 1: {
            return 1;
        } break;
        case 2: {
            return 0;
        } break;
        case 3: {
            return 3;
        } break;
        case 4: {
            return 2;
        } break;
        default: {
            return -1;
        } break;
    }
}

- (UIViewController *)pageViewController:(XLPageViewController *)pageViewController viewControllerForIndex:(NSInteger)index {
    LCTaskListViewController * listVC = [LCTaskListViewController xx_instantiateFromStoryboardNamed:@"Task"];
    listVC.parentVC = self.parentVC;
    listVC.orderType = [self orderTypeWithIndex:index];
    return listVC;
}

- (NSString *)pageViewController:(XLPageViewController *)pageViewController titleForIndex:(NSInteger)index {
    return self.titleArr[index];
}

- (NSInteger)pageViewControllerNumberOfPage {
    return self.titleArr.count;
}

- (void)pageViewController:(XLPageViewController *)pageViewController didSelectedAtIndex:(NSInteger)index {
}

@end
